#ifndef COLORMAP_H
#define	COLORMAP_H

#include <string>
#include <iostream>
#include <vector>
#include <map>
#include "Color.h"
#include "rfftw.h"

class ColorMap
{    
    public:
    
        enum ColorMode {BlackWhite, Rainbow, Ocean, CustomHue, ColorModeCount};
        enum ScaleMode {AUTO, MANUAL};
    
    private:
        
        ColorMode d_scalar_col;        
        ScaleMode d_scale;
        int d_levels;
        
        double d_min;
        double d_max;
        double d_clampMin;
        double d_clampMax;
        
        double d_h;
        double d_s;
        double d_v;
        
        bool d_constH;
        bool d_constS;
        bool d_constV;
        
        std::string d_name;        
        
        std::vector<Color> d_cols;
        std::vector<Color> d_map;
       
    
    public:
        ColorMap();        
        ColorMap(std::vector<Color> const &cols);
        
        void set(double vy);
        void set(int idx);
        void colorMode(int mod);
        void scaleMode(int mod);
        ColorMode colorMode();
        ScaleMode scaleMode();
        
        int levels();
        void levels(int l);
        
        double saturation();
        void saturation(double s);
        
        double hue();
        void hue(double h);
        
        double value();
        void value(double v);
        
        double minimum();
        void minimum(double min);
        
        double maximum();
        void maximum(double max);
        
        double clampMin();
        void clampMin(double cm);
        
        double clampMax();
        void clampMax(double cm);
        
        double usedMin();
        double usedMax();
        
        bool constH();
        bool constS();
        bool constV();
        
        std::vector<std::string> colorModeNames();
        std::vector<std::string> scaleModeNames();

    private:
        void rainbow(float value, float* R, float* G, float* B);   
        void ocean(float value, float* R, float* G, float* B);
        
        void buildMap();
        void buildColVec();
        Color interColor(int id1, int id2, float val);
        
        std::vector<std::string> d_colormode_names;
        std::vector<std::string> d_scalemode_names;
    
};


inline void ColorMap::scaleMode(int mod) { d_scale = ScaleMode(mod); }

inline ColorMap::ColorMode ColorMap::colorMode() { return d_scalar_col; }

inline ColorMap::ScaleMode ColorMap::scaleMode() { return d_scale; }

inline int ColorMap::levels() { return d_levels; }

inline void ColorMap::maximum(double max) { d_max = max; }

inline void ColorMap::minimum(double min) { d_min = min; }

inline double ColorMap::maximum() { return d_max; }

inline double ColorMap::minimum() { return d_min; }

inline void ColorMap::hue(double h) { d_h = h; }

inline void ColorMap::saturation(double s) { d_s = s; }

inline void ColorMap::value(double v) { d_v = v; }

inline void ColorMap::clampMin(double cm) { d_clampMin = cm; }

inline void ColorMap::clampMax(double cm) { d_clampMax = cm; }

inline double ColorMap::hue() { return d_h; }

inline double ColorMap::saturation() { return d_s; }

inline double ColorMap::value() { return d_v; }

inline bool ColorMap::constH() { return d_constH; }

inline bool ColorMap::constS() { return d_constS; }

inline bool ColorMap::constV() { return d_constV; }

inline std::vector<std::string> ColorMap::colorModeNames() { return d_colormode_names; }

inline std::vector<std::string> ColorMap::scaleModeNames() { return d_scalemode_names; }


#endif	/* COLORMAP_H */

